package com.ruoyi.framework.config;

/**
 * @author abel lee
 * @create 2020-07-28 10:16
 **/

import liquibase.integration.spring.SpringLiquibase;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.sql.DataSource;

@Component("LiquibaseConfig")
public class LiquibaseConfig {
    private static final Logger log = LoggerFactory.getLogger(LiquibaseConfig.class);

    @Bean()
    public SpringLiquibase liquibase(DataSource dataSource) {
        log.info("springLiquibase start ----->");
        SpringLiquibase liquibase = new SpringLiquibase();
        liquibase.setDataSource(dataSource);
        //指定changelog的位置，这里使用的一个master文件引用其他文件的方式
        liquibase.setChangeLog("classpath:liquibase/master.xml");
        liquibase.setContexts("dev,test,prod");
        liquibase.setShouldRun(true);
        return liquibase;
    }

}